/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package BookTransaction;

import Book.BookBean;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.Vector;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Mukesh
 */
public class GetReminder extends HttpServlet {

    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
            int days = Integer.parseInt(request.getParameter("days"));
            Vector list = BookTransaction.Query.getReminder(days);
            Iterator it = list.iterator();
            while (it.hasNext()) {
                BookTransBean btb = (BookTransBean) it.next();
                BookBean bb = btb.getBookBean();

                out.println("<tr id='" + btb.getBookTransactionId() + "'>");
                out.println("<td><center>");
                out.println(btb.getBookNo());
                out.println("</center></td>");
                out.println("<td><center>");
                out.println(bb.getBookName());
                out.println("</center></td>");
                out.println("<td><center>");
                out.println(btb.getRetruningDate());
                out.println("</center></td>");
                out.println("<td><center>");
                out.println(btb.getIssueDate());
                out.println("</center></td>");
                out.println("<td><center>");
                if (btb.getUserType() == 1) {
                    out.println("Employee");
                } else if (btb.getUserType() == 2) {
                    out.println("Student");
                }
                out.println("</center></td>");
                out.println("</tr>");
            }
        } catch (Exception e) {
            out.println("Notification Not Found.(e)");
        } finally {
            out.close();
        }
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>

}
